home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / README.TXT < prev    next >
Text File  |  1997-12-11  |  12KB  |  240 lines

  1.               Hardcore Visual Basic, Second Edition
  2.  
  3.                  Copyright 1997, Microsoft Press
  4.  
  5. The CD contains the sample programs for the book Hardcore Visual
  6. Basic. Since the legalese on the license agreement page is a little
  7. hard to interpret, let me clarify your rights to use the code.
  8. Copyright law protects written publication--in other words, your right
  9. to republish printed source code. The terms are spelled out in the
  10. license agreement. But you're probably not interested in publishing
  11. the source; you just want to use the code in your programs. That's
  12. what it's for. If you paid for it, it's yours. Microsoft does not
  13. claim ownership of the algorithms.
  14.  
  15. Sample Programs
  16. ---------------
  17.  
  18. You can examine sample programs in three ways. Let's say you want to
  19. start with the Fun 'n Games program from Chapter 7. This program
  20. illustrates graphics techniques. You can start by running FUNNGAME.EXE
  21. to see what it does. The setup program copies the sample programs to
  22. the Exes directory on your hard disk.
  23.  
  24. Sample EXE programs will work from your local disk if you ran the
  25. setup program or registered the components using the batch files
  26. described later. FUNNGAME.EXE uses four of the components described in
  27. the book. The VBCore.DLL component provides miscellaneous services.
  28. VisualCore.DLL provides forms wrapped in public classes--Fun 'N Games
  29. uses CColorPicker and COpenPictureFile. SubTimer.DLL is a small
  30. component that provides timer and subclassing services--Fun 'n Games
  31. uses CTimer. Finally, the program uses the XPictureGlass control from
  32. PictureGlass.OCX.
  33.  
  34. After you've clicked on a few buttons and been amazed by swirling
  35. cars, a spiraling ball, and shuffled cards, you'll probably want to
  36. see what makes these tricks work. The next step is to go to the
  37. directory created by the setup program (Hardcore2 by default) and load
  38. the project FUNNGAME.VBP into the Visual Basic IDE. You can step
  39. through the program and examine any of its code as an example of how
  40. to call the same components from your own programs.
  41.  
  42. You can stop right there if you want, but most hardcore programmers
  43. will probably want to take the next step and look inside the
  44. components. You can't do that from the VBP file because it references
  45. the compiled components. So you load the project group FUNNGAME.VBG.
  46. This one includes VBCore.VBP, VisualCore.VBP, and PictureGlass.VBP
  47. (but not SubTimer.VBP). You can step from the program into the more
  48. than 80 classes and modules of VBCore, or check out the five lines of
  49. new code I wrote to create the XPictureGlass control.
  50.  
  51. If you're really hardcore and want to see the whole thing, you can
  52. load FUNNGAMEDEB.VBG, which adds SubTimer.VBP to the mix. FUNNGAME.VBG
  53. references the compiled SubTimer.DLL and not the project because, as
  54. Chapter 6 explains, it's notoriously difficult to debug subclassing or
  55. timer code that uses callbacks. That's why the code is in the SubTimer
  56. component rather than in VBCore.
  57.  
  58. You might not have noticed in your haste to get your hands on the
  59. code, but the package around the CD is actually a free book. It won't
  60. compile or run, but you can read it in bed. Check out Chapter 5 where
  61. the project layout is explained in more detail.
  62.  
  63. Directory Layout
  64. ----------------
  65.  
  66. The directory installed by setup looks like this:
  67.  
  68. Hardcore2               Sample project and source files, README
  69.     Compare             Compatibility files for components
  70.     Debug               Debug versions of components
  71.     Exes                Executable sample programs
  72.     Goodies             Extra tools from readers of the first edition
  73.     LocalModules        Private versions of classes and standard modules
  74.     Release             Release versions of components
  75.     Tools               RegSvr32.EXE
  76.  
  77. Chapter 5 describes the differences between Debug and Release versions
  78. of components.
  79.  
  80. Setup Notes
  81. -----------
  82.  
  83. Setup is very simple. It simply copies the most important files from
  84. the CD to a directory you specify (default Hardcore2). It then
  85. registers components and type libraries.
  86.  
  87. You can undo the work done by the setup program by uninstalling with
  88. the Add/Remove Programs applet from the Control Panel. You can also do
  89. the same operations by hand. To uninstall the components, run the
  90. UNREGISTERALL.BAT file. There are also batch files to register either
  91. debug or release versions of the components--TODEBUG.BAT and
  92. TORELEASE.BAT.
  93.  
  94. Unfortunately, I have no utility to unregister type libraries. You can
  95. unregister the ANSI and Unicode versions of the Windows API type
  96. library by removing keys 64674040 and 64675040 from the TypeLib key
  97. under HKEY_CLASSES_ROOT in the system registry.
  98.  
  99. After unregistering all tools, you can delete any directories you
  100. don't want.
  101.  
  102. Setup copies CARDS32.DLL (used in the Fun 'n Games program) to your
  103. Windows directory. You can delete this DLL if you have no interest in
  104. programming card games.
  105.  
  106. If you run setup under Microsoft Windows NT, it copies PSAPI.DLL to
  107. your system directory. This DLL is required for iterating through
  108. processes and modules. It is described in Chapter 6. The WinWatch
  109. utility uses it under Windows NT only. If you have a dual-boot system
  110. and install under Microsoft Windows 95, the setup will not copy
  111. PSAPI.DLL to your Windows NT system directory (because it doesn't know
  112. where the directory is). In this case, you must copy PSAPI.DLL by
  113. hand.
  114.  
  115. Goodies
  116. -------
  117.  
  118. Readers of the first edition of my book answered some of my
  119. challenges, and some of their own. The Goodies directory has some
  120. interesting code and components. Some are source code samples. Others
  121. are licensed controls. I'm giving these out as a courtesy, but the
  122. authors (who are listed in README files in each directory) are
  123. responsible. Setup installs the directories, but you'll need to
  124. manually run setup programs for some of them. If you decide to remove
  125. a tool, make sure you unregister it before deleting the files so that
  126. you don't leave orphaned entries in the registry.
  127.  
  128. The programs in the Goodies directory are the ones available at the
  129. time the book was published. The Hardcore Hackers' Hall of Fame on my
  130. web site may have more goodies and later versions of some of the the
  131. originals. You can see the latest at:
  132.  
  133. www.pobox.com/HardcoreVB/hackhall.htm.
  134.  
  135. The Source directory on the CD contains some C++ articles I wrote for
  136. the Microsoft Developer Network CD and for Visual Basic Programmer's
  137. Journal. Although the components and DLLs described in them are for
  138. Visual Basic, they're written in C++. I didn't think these would be of
  139. general interest to readers of the book, so the setup program doesn't
  140. copy them to your disk. The source for the Windows API type library is
  141. also in this directory.
  142.  
  143. Bugs! What bugs?
  144. ---------------
  145.  
  146. There are a few differences between the code on the CD and the code in
  147. the book. Fortunately, many of these are improvements rather than
  148. fixed bugs:
  149.  
  150.  - The BytesToStr function on page 279 is incorrect. The correct code
  151.    is shown below:
  152.  
  153.         Function BytesToStr(ab() As Byte) As String
  154.             BytesToStr = StrConv(ab, vbUnicode)
  155.         End Function
  156.  
  157.    This code is correct on the CD.
  158.  
  159.  - The code examples on pages 249-251 illustrate the error scheme used
  160.    throughout my components. It uses one of the largest modules,
  161.    Utility.Cls, but this module changed after the chapter was finished.
  162.    A new error was added to the EErrorUtility Enum, VBCore's resource
  163.    table, and the local ErrRaise procedure.
  164.  
  165.  - The description on page 353 states that my subclassing mechanism
  166.    expects one message per class (middle of the page). Fortunately,
  167.    this statement is false, as the CPalette class in VBCore proves. A
  168.    class that implements ISubclass can handle as many messages as it
  169.    wants as long as it attaches each of them with AttachMessage and
  170.    handles them in the ISubclass_WindowProc method. In other words,
  171.    the subclassing mechanism is even more flexible than I thought when
  172.    I wrote the code. The second limitation described in the same
  173.    paragraph--that you couldn't write several different classes to
  174.    handle the same message--is true.
  175.  
  176.  - The AnimateBacks procedure shown on pages 426 and 427 had a bug. An
  177.    early exit through a conditional Exit Sub failed to restore the
  178.    ScaleMode saved at the beginning of the procedure. The results of
  179.    drawing in twips mode when the machine is still in pixel mode
  180.    aren't pretty. The code is correct on the CD.
  181.  
  182.  - The "Palette tricks" section on page 461 was purposely vague
  183.    because when I wrote it I didn't really know how to manage palettes
  184.    in Visual Basic. Now I do--at least partly. The CPalette class and
  185.    the TPalette program were finished in the wee hours of the morning
  186.    before we shipped. What I wrote for the book wasn't too bad, but
  187.    subclassing is mandatory, not optional, and the AutoRedraw setting
  188.    mentioned in the text doesn't really have much to do with anything.
  189.    The comments in the source for the CPalette class and the TPalette
  190.    program explain palettes in more detail.
  191.  
  192.  - The Add method of the XListBoxPlus control has an extra optional
  193.    parameter that isn't shown in the listing on page 619. The new
  194.    parameter is an ItemData member that allows you to add string items
  195.    and numeric item data with one statement. Instead of this:
  196.  
  197.         lst.AddItem "WindowText"
  198.         lst.ItemData(lst.NewIndex) = hWnd
  199.  
  200.    Do this:
  201.  
  202.         list.Add "WindowTest", , hWnd
  203.  
  204.    The same listing also fails to call the PropertyChanged method to
  205.    let the property page know the List property has changed. This
  206.    omission is fixed on the CD.
  207.  
  208.  - The performance sidebar on page 671 has the wrong timings in the
  209.    p-code column. It might be nice if p-code were the same speed as
  210.    native code, but the correct numbers are:
  211.  
  212.      Problem                                Native code     P-code
  213.      -------                                -----------   ----------
  214.      Find files with Basic Dir$             39 seconds    49 seconds
  215.      Find files with FindFirstFile API       9 seconds    13 seconds
  216.      User the Windows Explorer Find dialog   6 seconds     6 seconds
  217.  
  218.  - I'm sorry to say that the Meriwether Explorer application described
  219.    on pages 680 and 681 isn't much better than the pitiful Columbus
  220.    application provided with the first edition. In fact, this version
  221.    does even less, although it has more potential. I got the program
  222.    working just in time to get a screen dump for the book, but I
  223.    planned to spend more time polishing it before the CD shipped.
  224.    Well, other things came up, and I didn't work with Meriwether
  225.    much more. Fortunately, this version is based on a more flexible
  226.    architecture. Unlike Columbus, it shows the whole namespace and
  227.    does so at an acceptable speed. You should be able to enhance it
  228.    into a usable replacement for Windows Explorer.
  229.  
  230. I'm sure there are other problems that I haven't discovered yet. I did
  231. my best to write bug-free code, but when I had a choice between adding
  232. interesting features or testing existing code, I added the new
  233. features. These samples are not as bullet-proof as I would have made
  234. them had I been shipping programs without source. I apologize for any
  235. bugs. Please send any bug fixes or enhancements to brucem@pobox.com. I
  236. will fix and distribute them on my web site.
  237.  
  238. Bruce McKinney
  239. www.pobox.com/HardcoreVB
  240.